import java.util.Random;

/**
 * 数组其他
 */
public class Demo03 {
  public static void main(String[] args) {
    //下标越界
    int[] ages = {1,2,3,4};//0~3
//    System.out.println(ages[4]);//java.lang.ArrayIndexOutOfBoundsException: 4
    System.out.println(ages[0]);
//    System.out.println(ages[-1]);//ArrayIndexOutOfBoundsException: -1

    for(int item : ages){
      System.out.println(item);
    }

    for(int i=0;i<ages.length;i++){
      ages[i] += 1;
    }

    Random random = new Random();
    for(int i=100;i>0;i--){
      System.out.println(random.nextInt(20)+1);
    }
  }
}
